package com.caiyi.financial.nirvana.sms.service;

import com.caiyi.financial.nirvana.sms.base.service.BaseService;
import com.caiyi.financial.nirvana.sms.entity.SmsAdmin;
import com.caiyi.financial.nirvana.sms.mapper.SmsAdminMapper;
import com.caiyi.financial.nirvana.sms.querybean.AdminQueryBean;
import com.caiyi.financial.nirvana.sms.querybean.PageBean;
import com.caiyi.financial.nirvana.sms.vo.SmsAdminVo;
import com.github.pagehelper.PageHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * Created by Mario on 2018/1/3 0003.
 * 管理后台用户表
 */
@Service
public class SmsAdminService extends BaseService<SmsAdmin> {

    @Autowired
    private SmsAdminMapper smsAdminMapper;

    /**
     * 根据账号查询用户
     *
     * @param account 账号
     * @return 管理后台用户
     */
    public SmsAdmin selectByAccount(String account) {
        return smsAdminMapper.selectAccount(account);
    }

    //查询所有账号
    public PageBean<SmsAdminVo> getAdminByParams(AdminQueryBean bean) {
        PageHelper.startPage(bean.getPageNum(), bean.getPageSize());
        List<SmsAdminVo> list = smsAdminMapper.getAllAdmin(bean);
        PageBean<SmsAdminVo> pageBean = new PageBean<>(list);
        return pageBean;
    }
}
